org.springframework.data.document.mongodb.convert
Class AbstractMongoConverter

java.lang.Object
  extended by org.springframework.data.document.mongodb.convert.AbstractMongoConverter
All Implemented Interfaces:
MongoConverter, MongoReader<java.lang.Object>, MongoWriter<java.lang.Object>
Direct Known Subclasses:
MappingMongoConverter, SimpleMongoConverter

public abstract class AbstractMongoConverter
extends java.lang.Object
implements MongoConverter

Author:
Jon Brisbin

Nested Class Summary
private static class AbstractMongoConverter.CustomToStringConverter
           
 
Field Summary
protected  GenericConversionService conversionService
           
private  java.util.Set<ConvertiblePair> customTypeMapping
           
private static java.util.List<java.lang.Class<?>> MONGO_TYPES
           
 
Constructor Summary
AbstractMongoConverter(GenericConversionService conversionService)
           
 
Method Summary
 void afterPropertiesSet()
           
 ConversionService getConversionService()
           
protected  java.lang.Class<?> getCustomTarget(java.lang.Class<?> source, java.lang.Class<?> expectedTargetType)
           
private  void initializeConverters()
          Registers converters for ObjectId handling, removes plain Object.toString() converter and promotes the configured ConversionService to MappingBeanHelper.
 java.lang.Object[] maybeConvertArray(java.lang.Object[] src)
           
 BasicDBList maybeConvertList(BasicDBList dbl)
           
 java.lang.Object maybeConvertObject(java.lang.Object obj)
           
private  void registerConverter(java.lang.Object converter)
          Inspects the given AbstractMongoConverter.CustomToStringConverter for the types it can convert and registers the pair for custom type conversion in case the target type is a Mongo basic type.
 void setCustomConverters(java.util.Set<?> converters)
          Add custom AbstractMongoConverter.CustomToStringConverter or ConverterFactory instances to be used that will take presidence over metadata driven conversion between of objects to/from DBObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.data.document.mongodb.convert.MongoConverter
convertObjectId, convertObjectId, getMappingContext
 
Methods inherited from interface org.springframework.data.document.mongodb.MongoWriter
write
 
Methods inherited from interface org.springframework.data.document.mongodb.MongoReader
read
 

Field Detail

MONGO_TYPES

private static final java.util.List<java.lang.Class<?>> MONGO_TYPES

conversionService

protected final GenericConversionService conversionService

customTypeMapping

private final java.util.Set<ConvertiblePair> customTypeMapping
Constructor Detail

AbstractMongoConverter

public AbstractMongoConverter(GenericConversionService conversionService)
Method Detail

setCustomConverters

public void setCustomConverters(java.util.Set<?> converters)
Add custom AbstractMongoConverter.CustomToStringConverter or ConverterFactory instances to be used that will take presidence over metadata driven conversion between of objects to/from DBObject

Parameters:
converters -

initializeConverters

private void initializeConverters()
Registers converters for ObjectId handling, removes plain Object.toString() converter and promotes the configured ConversionService to MappingBeanHelper.


registerConverter

private void registerConverter(java.lang.Object converter)
Inspects the given AbstractMongoConverter.CustomToStringConverter for the types it can convert and registers the pair for custom type conversion in case the target type is a Mongo basic type.

Parameters:
converter -

getCustomTarget

protected java.lang.Class<?> getCustomTarget(java.lang.Class<?> source,
                                             java.lang.Class<?> expectedTargetType)

getConversionService

public ConversionService getConversionService()
Specified by:
getConversionService in interface MongoConverter

afterPropertiesSet

public void afterPropertiesSet()

maybeConvertObject

public java.lang.Object maybeConvertObject(java.lang.Object obj)
Specified by:
maybeConvertObject in interface MongoConverter

maybeConvertArray

public java.lang.Object[] maybeConvertArray(java.lang.Object[] src)
Specified by:
maybeConvertArray in interface MongoConverter

maybeConvertList

public BasicDBList maybeConvertList(BasicDBList dbl)
Specified by:
maybeConvertList in interface MongoConverter